package com.falm.picturebackend.entity.convert;

import com.falm.picturebackend.entity.BO.UserBO;
import com.falm.picturebackend.entity.DO.UserDO;
import com.falm.picturebackend.entity.VO.UserVO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Administrator
 */
public class UserConvert {

    public static UserBO do2BO(UserDO userDO) {
        if (userDO == null) {
            return null;
        }
        UserBO userBO = new UserBO();
        userBO.setUserAccount(userDO.getUserAccount());
        userBO.setUserPassword(userDO.getUserPassword());
        userBO.setUserName(userDO.getUserName());
        userBO.setUserAvatar(userDO.getUserAvatar());
        userBO.setUserProfile(userDO.getUserProfile());
        userBO.setUserRole(userDO.getUserRole());
        userBO.setVipExpireTime(userDO.getVipExpireTime());
        userBO.setVipCode(userDO.getVipCode());
        userBO.setVipNumber(userDO.getVipNumber());
        return userBO;
    }

    public static UserDO bo2DO(UserBO userBO) {
        if (userBO == null) {
            return null;
        }
        UserDO userDO = new UserDO();
        userDO.setUserAccount(userBO.getUserAccount());
        userDO.setUserPassword(userBO.getUserPassword());
        userDO.setUserName(userBO.getUserName());
        userDO.setUserAvatar(userBO.getUserAvatar());
        userDO.setUserProfile(userBO.getUserProfile());
        userDO.setUserRole(userBO.getUserRole());
        userDO.setVipExpireTime(userBO.getVipExpireTime());
        userDO.setVipCode(userBO.getVipCode());
        userDO.setVipNumber(userBO.getVipNumber());
        return userDO;
    }

    public static UserVO bo2VO(UserBO userBO) {
        if (userBO == null) {
            return null;
        }
        UserVO userVO = new UserVO();
        userVO.setUserAccount(userBO.getUserAccount());
        userVO.setUserName(userVO.getUserName());
        userVO.setUserAvatar(userBO.getUserAvatar());
        userVO.setUserProfile(userBO.getUserProfile());
        userVO.setUserRole(userBO.getUserRole());
        userVO.setVipExpireTime(userBO.getVipExpireTime());
        userVO.setVipCode(userBO.getVipCode());
        userVO.setVipNumber(userBO.getVipNumber());
        return userVO;
    }


    public static List<UserBO> do2BOList(List<UserDO> userDOList) {
        return userDOList.stream().map(UserConvert::do2BO).collect(Collectors.toList());
    }
}